<?php

function HotelBooking_service_query(){
  $hotelid = FormUtil::getPassedValue('hotelid',FALSE);
  
  if (!$hotelid){
      return 'ERROR HotelBooking system can not find [hotelid]';
  }
  
  $result = array();
  
  //Hotel Description
  if (!($hotelMemberClass = Loader::loadClassFromModule ('HotelBooking', 'HotelMember', false))){
    return LogUtil::registerError ("Unable to load class [HotelMember] ...");
  }
  $hotelMemberObject  = new $hotelMemberClass ();
  
  if($hotelMemberObject->get($hotelid)){
    $result['hotelMember'] = $hotelMemberObject->getData();
  }
  
  //Hotel Room
  if (!($hotelRoomClass = Loader::loadClassFromModule ('HotelBooking', 'HotelRoom', true))){
    return LogUtil::registerError ("Unable to load class [HotelRoom] ...");
  }
  $hotelRoomObject  = new $hotelRoomClass ();
  $where = $hotelRoomObject->_columns['hotelMember_id']." = ".$hotelid;
  
  if($hotelRoomObject->get($where)){
    $result['hotelRoom'] = $hotelRoomObject->getData();
  }
  
  
  //Hotel Season
  if (!($hotelSeasonClass = Loader::loadClassFromModule ('HotelBooking', 'HotelSeason', true))){
    return LogUtil::registerError ("Unable to load class [HotelSeason] ...");
  }
  $hotelSeasonObject  = new $hotelSeasonClass ();
  $where = $hotelSeasonObject->_columns['hotelMember_id']." = ".$hotelid;
  
  if($hotelSeasonObject->get($where)){
    $result['hotelSeason'] = $hotelSeasonObject->getData();
  }
  
  
  //Hotel Promotion
  if (!($hotelPromotionClass = Loader::loadClassFromModule ('HotelBooking', 'HotelPromotion', true))){
    return LogUtil::registerError ("Unable to load class [HotelPromotion] ...");
  }
  $hotelPromotionObject  = new $hotelPromotionClass ();
  $where = $hotelPromotionObject->_columns['hotelMember_id']." = ".$hotelid;
  
  if($hotelPromotionObject->get($where)){
    $result['hotelPromotion'] = $hotelPromotionObject->getData();
  }
  
  //Hotel News
  if (!($hotelNewsClass = Loader::loadClassFromModule ('HotelBooking', 'HotelNews', true))){
    return LogUtil::registerError ("Unable to load class [HotelNews] ...");
  }
  $hotelNewsObject  = new $hotelNewsClass ();
  $where = $hotelNewsObject->_columns['hotelMember_id']." = ".$hotelid;
  
  if($hotelNewsObject->get($where)){
    $result['hotelNews'] = $hotelNewsObject->getData();
  }
  
  //Hotel Images
  if (!($hotelImagesClass = Loader::loadClassFromModule ('HotelBooking', 'HotelImages', true))){
    return LogUtil::registerError ("Unable to load class [HotelImages] ...");
  }
  $hotelImagesObject  = new $hotelImagesClass ();
  $where = $hotelImagesObject->_columns['hotelMember_id']." = ".$hotelid;
  
  if($hotelImagesObject->get($where)){
    $result['hotelImages'] = $hotelImagesObject->getData();
  }
  
  //Hotel Rate
  if (!($hotelRateClass = Loader::loadClassFromModule ('HotelBooking', 'HotelRate', true))){
    return LogUtil::registerError ("Unable to load class [HotelRate] ...");
  }
  $hotelRateObject  = new $hotelRateClass ();
  $where = $hotelRateObject->_columns['hotelMember_id']." = ".$hotelid;
  
  if($hotelRateObject->get($where)){
    $result['hotelRate'] = $hotelRateObject->getData();
  }
  
  echo json_encode($result);
  exit;
}

function HotelBooking_service_search(){
  $hotelid      = FormUtil::getPassedValue ('hotelid', false);
  $startdate      = FormUtil::getPassedValue ('startdate', false);
  $stay      = FormUtil::getPassedValue ('stay', false);
  
  
}
?>